package com.hbvtc.xxxy.nikeSale.frames;

/*
 * 查询所有商品信息
 */
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import com.hbvtc.xxxy.nikeSale.utils.DbManager;

public class SelectShopNike extends JFrame {
	// Vector 可实现自动增长的对象数组
	Vector row, column;
	JTable lal = null;
	JScrollPane jsp = null;
	PreparedStatement pst = null;
	Connection conn = null;
	ResultSet res = null;
	String sql;

	public SelectShopNike() throws SQLException {
		this.setTitle("所有商品信息界面");
		this.setSize(1000, 700);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
		column = new Vector();
		column.add("商品编号");
		column.add("商品名称");
		column.add("商品价格");
		column.add("商品数量");
		row = new Vector();
		conn = DbManager.getconn();
		sql = "select GoodsID,GoodsName,SalePrice,StockNum from goods";
		pst = conn.prepareStatement(sql);
		res = pst.executeQuery();
		while (res.next()) {
			Vector vector = new Vector();
			vector.add(res.getInt(1));
			vector.add(res.getString(2));
			vector.add(res.getDouble(3));
			vector.add(res.getString(4));
			row.add(vector);
		}
		lal = new JTable(row, column);
		jsp = new JScrollPane(lal);
		this.add(jsp);
		this.setSize(1000, 700);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}

	public static void main(String[] args) {
		try {
			new SelectShopNike();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
